<!DOCTYPE html>
<html lang="en">
<head th:include="/public/public_css::public_css ('用户管理')" />
<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">包装名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="bzmc" id="test2" placeholder="包装名称" />
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">搜索</a>
                    </div>
                </form>
                <div class="group-button" id="toolbar">
                    <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 新增
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-normal" id="testupload">
                        <i class="layui-icon">&#x1005;</i> 上传
                    </a>
                    <!-- Single button -->
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body" >
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

<div id="uploadDialog" style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">
    <div class="layui-upload">
        <button type="button" class="layui-btn layui-btn-normal" id="testList">选择多文件</button>
        <div class="layui-upload-list">
            <table class="layui-table">
                <thead>
                <tr><th>文件名</th>
                    <th>大小</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr></thead>
                <tbody id="demoList"></tbody>
            </table>
        </div>
        <button type="button" class="layui-btn" id="testListAction">开始上传</button>
    </div>
</div>
</body>

</body>

<div th:include="/public/public_js::public_js"></div>

<style>
    #uploadDialog{
        display: none;
    }
</style>
<script>
    $(function () {

        $('.js-data-example-ajax').select2({
            ajax: {
                url: '/zxbzwms/wmsgoodstype/getWmsGoodsTypeByHzId',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        for (var i=0;i<data.length;i++){
                            arr.push({id:data[i].id,text:data[i].mc});
                        }
                    }
                    console.log(arr);
                    // Tranforms the top-level key of the response object from 'items' to 'results'
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询字段',
            allowClear: true
        });
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        })
    });

    $('#testupload').click(function () {
        layer.open({
            type: 1
            ,title: false //不显示标题栏
            ,closeBtn: false
            ,area: ['50%', '60%']
            ,shade: 0.2
            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
            ,btn: ['好']
            ,btnAlign: 'c'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: $('#uploadDialog')
        });
    })

    layui.use(['list','layer','zzpUtils','jquery','laydate'],function () {
        window.operateEvent ={
            "click #editRow":function (e, value, row, index) {
                editDialog(row.id);
            },
            "click #pile":function (e, value, row, index) {
                pileDialog(row.id);
            }
        }

        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;

        function editDialog(id){
            localStorage.id = id;
            zzpUtils.dialog({
                title:"修改包装信息",
                type:2,
                data:{
                    id:id
                },
                content: "/base/EditBaozhuang"
            });
            console.log('dialog打开');
        }

        function pileDialog(id){
            localStorage.id = id;
            zzpUtils.dialog({
                title:" 查看堆码信息",
                type:2,
                content: "/base/ViewPile",
                area: ['50%', '60%']
            });
        }

        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        })
        // 主页面table
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/wmspacking/list',
            columns: [
                {field: '', checkbox: true},
                {field: "hzmc", title: "货主名称"},
                {field: "bzmc", title: "包装名称"},
                {field: "bzms", title: "包装描述"},
                {
                    field:'caozuo',
                    title: '操作',
                    events:operateEvent,
                    formatter:operateFormatter
                }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }

        });

        function operateFormatter(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-xs" id="editRow">编辑</a>',
                '<a class="layui-btn layui-btn-danger layui-btn-xs" id="pile">堆码</a>'
            ].join('')
        }

        $(".inline-search-btn").on('click',function () {
            zzpUtils.refreshTable("#table");
        })
        $(".add-btn").on('click',function () {
            zzpUtils.dialog({
                title:"添加包装",
                type:2,
                content: "/base/AddBaozhuang",
                btn:[],
            });
        })

    });
</script>

</html>